/* 引入Vue */
import Vue from 'vue'
/* 引入VueRouter */
import Router from 'vue-router'

/* 常量路由 */
import {constantRoutes} from '@/router/routes/constantRoutes'
/* 异步路由 */
// import asyncRoutes from '@/router/routes/asyncRoutes'

Vue.use(Router)

/* createRouter()函数用于创建一个Router实例并返回 */
const createRouter = () => new Router({
  mode: 'hash',
  scrollBehavior: () => ({y: 0}),
  routes: constantRoutes
})

/* 调用createRouter()函数，创建Router实例 */
const router = createRouter()

/* resetRouter()重置路由的函数 */
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher
}

export default router
